﻿using System;
using EntityMapping.Models;
using FluentPS.Services.Impl;

namespace EntityMapping
{
    public class ResourceMappingTest
    {
        private const string _accountName = "domain\\login"; // set account name here

        public void Run()
        {
            var logService = new LogService();
            var sessionService = new SessionService();
            var resourceService = new PSResourceService<User>(logService, sessionService);

            Console.WriteLine(string.Format("Get resource UID by account name: {0}", _accountName));
            var uid = resourceService.GetResourceUidByUserAccount(_accountName);
            Console.WriteLine(string.Format("UID: {0}", uid));

            Console.WriteLine(string.Format("Load resource by UID: {0}", uid));
            var user = resourceService.Get(uid);
            Console.WriteLine(string.Format("CustomUserField: {0}", user.CustomUserField));

            user.CustomUserField += " updated";

            Console.WriteLine("Update resource");
            resourceService.Update(user);

            Console.WriteLine("Exit");
        }
    }
}
